
package com.ansion.commonchat.contact.utils;

import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.Point;
import android.net.Uri;
import android.os.Build;
import android.os.Parcelable;
import android.provider.Browser;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.core.text.TextUtilsCompat;
import androidx.core.view.ViewCompat;


import com.ansion.basedb.dao.LoginedUserMgr;
import com.ansion.basedb.dao.model.CurrentUser;
import com.ansion.constant.BConstant;
import com.ansion.string.StringUtils;
import com.ansion.utils.LanguageSettingHelper;
import com.ansion.utils.ResourceUtils;
import com.ansion.utils.hanzi2pinyin.PinyinUtil2;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;



public class HelperFunc {

	private static final String TAG = "HelperFunc";

	public static String getAlpha(String str) {
		if (str == null) {
			return "#";
		}

		if (str.trim().length() == 0) {
			return "#";
		}

		char firstChar = str.trim().charAt(0);

		if (StringUtils.isDigital(firstChar)) {
			return "#";
		}

		if (StringUtils.isAlpha(firstChar)) {
			return String.valueOf(firstChar);
		}

		if (StringUtils.isArabChar(firstChar)) {
			return firstChar + "";
		}

		String c = PinyinUtil2.hanziToPinyin(str);
		if (!TextUtils.isEmpty(c)) {
			c = c.trim();
			if (c.length() > 0) {
				firstChar = c.charAt(0);
				if (StringUtils.isAlpha(firstChar)) {
					return c.toUpperCase();
				}
			} else {
				return "#";
			}
		}
		return "#";
	}

}

